﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.Common;

namespace lcmyjobs.Web.users
{
    public partial class reg_name : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                txtaddress.Attributes.Add("readonly", "true");
                txthuji.Attributes.Add("readonly", "true");

                this.Title = string.Format("个人会员注册：基本资料&bull;联系方式   {0}", Application["webname"].ToString());
            }

        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string name = this.txtname.Text;
                string pwd = this.txtpwd.Text;
                pwd = myPublic.GetMd5(pwd);
                string truename = this.txttruename.Text;
                bool sex;
                if (rbtMan.Checked)
                    sex = true;
                else
                    sex = false;
                int age = int.Parse(this.txtage.Text);
                int height = int.Parse(this.txtheight.Text);
                string address = this.txtaddress.Text;
                string huji = this.txthuji.Text;
                string email = this.txtemail.Text;
                string phone = this.txtphone.Text;
                string onlinecontact = this.txtonlinecontact.Text;
                lcmyjobs.Model.user_basic model = new lcmyjobs.Model.user_basic();
                model.name = name;
                model.pwd = pwd;
                model.truename = truename;
                model.sex = sex;
                model.age = age;
                model.height = height;
                model.address = address;
                model.huji = huji;
                model.email = email;
                model.phone = phone;
                string line = "";                
                if (rbtQQ.Checked)
                    line = "QQ：";
                if (rbtMSN.Checked)
                    line = "MSN:";
                if (rbtUC.Checked)
                    line = "UC:";
                if (onlinecontact.Trim()!="")
                model.onlinecontact =line+ onlinecontact;
                lcmyjobs.BLL.user_basic bll = new lcmyjobs.BLL.user_basic();
                int webid=int.Parse(Application["webid"].ToString());
                int i = bll.Add(model,webid,0);
                if (i != 0)
                {
                    Session["user_id_reg"] = i.ToString();
                    string truenamesex = txttruename.Text.Trim();
                    if (this.rbtMan.Checked)
                    {
                        truenamesex += " 先生";
                    }
                    else
                    {
                        truenamesex += " 女士";
                    }
                    Session["user_name_reg"] = truenamesex;
                    Response.Redirect("reg_edu.aspx");
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this, "注册失败！");
                }
            }
        }
    }
}